package days29.Title226;

class Solution {
    public TreeNode invertTree(TreeNode root) {
        reverse(root);
        return root;
    }
    public void reverse(TreeNode root){
        if (root!=null){
            TreeNode tmp = root.right;
            root.right = root.left;
            root.left = tmp;
            reverse(root.left);
            reverse(root.right);
        }
    }
}